package com.ganzalang.gmall.promotion.service.rule.condition.factory;

import com.ganzalang.gmall.promotion.enums.EnjoyConditionEnum;
import com.ganzalang.gmall.promotion.service.rule.condition.EnjoyConditionStrategy;
import com.ganzalang.gmall.promotion.service.rule.condition.impl.FullAmountFullPieceComposite;
import com.ganzalang.gmall.promotion.service.rule.condition.impl.FullAmountStragetyImpl;
import com.ganzalang.gmall.promotion.service.rule.condition.impl.FullPieceStragetyImpl;
import com.ganzalang.gmall.promotion.service.rule.condition.impl.TheNStragetyImpl;

/**
 * @description: 满足享受促销活动条件的工厂
 * @author: Ganzalang
 * @Date 2022/4/11 10:59
 */
public class EnjoyConditionFactory {

    public static EnjoyConditionStrategy getBean(Integer type) {
        EnjoyConditionEnum enjoyConditionEnum = EnjoyConditionEnum.valueOf(type);
        switch (enjoyConditionEnum) {
            case FULL_AMOUNT:
                return new FullAmountStragetyImpl();
            case FULL_PIECE:
                return new FullPieceStragetyImpl();
            case THE_N:
                return new TheNStragetyImpl();
            case FULL_AMOUNT_FULL_PIECE:
//                EnjoyConditionStrategy fullAmountStragety = new FullAmountStragetyImpl();
//                fullAmountStragety = new FullAmountDecorator(fullAmountStragety);
                FullAmountFullPieceComposite root = new FullAmountFullPieceComposite();
                root.add(new FullAmountStragetyImpl());
                root.add(new FullPieceStragetyImpl());
                return root;
            default:
                return null;
        }
    }
}
